package com.lkl.hystrixdemo.order.mapper;

import com.lkl.hystrixdemo.order.model.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

@Mapper
@CacheConfig(cacheNames = {"userCache"})
public interface UserMapper {
    @Insert("INSERT INTO user (id, userName, email) values (#{id}, #{username}, #{email})")
    int addUser(User user);

    @Select("select * from user")
    @Cacheable(key = "getAllUser")
    List<User> findAllUser();

}
